package com.sdy.dcsb;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.client.RestTemplate;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.MultipartConfigElement;

/**
 * Spring Boot Application
 *
 * @see <a href="https://spring.io/projects/spring-boot">Spring Boot</a>
 */
@SpringBootApplication // 启用@EnableAutoConfiguration @ComponentScan
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {
        "com.sdy.auth.api",
        "com.sdy.fs.api",
        "com.sdy.resdir.api",
        "com.sdy.usercenter.api"})
@EnableAsync
@EnableSwagger2
public class MyApplication {
    public static void main(String[] args) {

        SpringApplication.run(MyApplication.class, args);
    }

    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }


    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        /**
         * 单个数据大小
         */
        factory.setMaxFileSize("10240KB");
        /**
         * 总上传数据大小
         */
        factory.setMaxRequestSize("102400KB");
        return factory.createMultipartConfig();
    }
}

